
<template>
	<view class="body">
		
		<view class="m1" v-if="flag">
			<view class="iconfont icon-denglu "></view>
			<text>{{username}}</text>
		</view>
		
		<view class="m1" @click="login" v-else>
			<view class="iconfont icon-denglu "></view>
			<text>未登录</text>
		</view>
		
		<view class="m2" @click="jianli">
			<view class="iconfont icon-wodejianli  "></view>
			<text>个人简历</text>
			<view class="iconfont icon-you  "></view>
		</view>
		
		<view class="m3" @click="chanping">
			<view class="iconfont icon-chanpin  "></view>
			<text>关于产品</text>
			<view class="iconfont icon-you  "></view>
		</view>
		
		<view class="m4" @click="zhuxiao" v-if="flag">
			<view class="iconfont icon-zhuxiao "></view>
			<text>注销登录</text>
			<view class="iconfont icon-you  "></view>
		</view>
		
		<view class="m4" @click="login" v-else>
			<view class="iconfont icon-zhuxiao "></view>
			<text>登录</text>
			<view class="iconfont icon-you  "></view>
		</view>
	</view>
</template>

<script>
	 export default {
		 data(){
		 	return{
				flag:'',
		 		username:'',
				value:''
		 	}
		 },
		 onLoad() {
		 	
		 },
		//监听器
		onShow() {
			try {
			    const value = uni.getStorageSync('token');
			    	if (value) {
			    		console.log("同步"+value);
			    		this.username=value,
			    		this.flag=true
			    	}else{
			    		//数据未获取成功，用户没有登录
			    		this.flag=false,
			    		uni.navigateTo({
			    			url: '/pages/my/my'
			    				
			    		});
			    	}
			} catch (e) {
			    console.log("失败");
			}
			
			
			},
		methods: {
			
			login(){
				console.log("登录详情页触发")
				uni.navigateTo({
					url:'../login/login'
				})
			},
			
			jianli(){
				console.log("简历详情页触发")
				uni.navigateTo({
					url:'../jianli/jianli'
				})
			},
			
			chanping(){
				console.log("产品详情页触发")
				uni.navigateTo({
					url:'../chanping/chanping'
				})
			},
			
			zhuxiao(){
				uni.removeStorage({
					key:'token',
					success:()=>{
						uni.showToast({
							title: '注销成功'
						});
						console.log("注销成功")
						/* uni.navigateTo({
							url: '/pages/my/my'
						}) */
						location.reload();
					},
				})
				
			}
		}
	    }
</script>

<style lang="scss">
	.body{
		
	}
	.m1{
		text-align: center;
		background-color: #fff;
		border-bottom: 2px solid #ccc;
		padding-bottom: 20px;
		width: 100%;
		view{
			width: 200rpx;
			height: 110rpx;
			/* background-color: #E88807; */
			/* border-radius: 60rpx; */
			margin: 25px auto;
			line-height: 120rpx;
			color: #6D6D72;
			font-size: 100px;
		}
		text{
			font-size: 20px;
			color: #ccc;
		}
	}
	
	.m2,.m3,.m4{
		display: flex;//在一行显示
		margin: 2px auto;
		background-color: #fff;
		padding: 10px 0px 10px 0px;
		border-bottom: 2px solid #ccc;
		view:nth-child(1){
			font-size: 25px;
			margin: auto 5px;
		}
		text{
			font-size: 20px;
			color: #6D6D72;
		}
		view:nth-child(3){
			color: #8F8F94;
			position: absolute;
			font-size: 25px;
			right: 5px;
			margin: auto 5px;
		}
	}
</style>